import 'package:flutter/material.dart';
import 'refresh_header.dart';
import 'refresh_footer.dart';
import 'refresh_empty.dart';
import 'refresh_first.dart';

typedef CallbackFunction = void Function(LoadMoreStatus loadMoreStatus,
    {bool isNoData});

/// 刷新成功或者失败等状态，外部提供请求结果
typedef OnLoadCallback = void Function(CallbackFunction callback);
typedef OnRefreshCallback = void Function(CallbackFunction callback);

/// 本地配置信息收集
enum LoadMoreStatus {
  /// 闲置状态
  idle,

  /// 刷新失败
  fail,

  /// 没有更多
  nomore,
}

class RefreshConfigure {
  /// 是否开启第一次刷新等待界面，默认不开启
  final bool isFirstStart;

  /// 刷新动作
  final OnRefreshCallback onRefresh;

  /// 加载更多动作
  final OnLoadCallback onLoad;

  /// 自定义尾组件
  RefreshFooter refreshFooter;

  /// 自定义头组件
  RefreshHeader refershHeader;

  /// 自定义第一次加载，无数据源组件
  Widget refreshEmpty;

  /// 自定义第一次刷新时，等待界面
  Widget refreshFirst;
  
  /// 没有数据时主动刷新
  Function callRefresh;

  /// type:1） - 不需要controller控制器的Widget滑动组件,EasyRefresh的constom  
  /// type:2） - 需要controller的Widget滑动组件(默认),EasyRefresh的原始构造 
  final int needContrType;
  static RefreshHeader defaultHeader = RefreshHeader();
  static RefreshFooter defaultFooter = RefreshFooter();
  static RefreshEmpty defaultEmpty = RefreshEmpty();
  static RefreshFirst defaultFirst = RefreshFirst();

  RefreshConfigure(
      {this.onRefresh,
      this.onLoad,
      this.refreshFooter,
      this.refershHeader,
      this.refreshFirst,
      this.refreshEmpty,
      this.isFirstStart = false,
      this.needContrType = 2});
}
